var htmlWebpackPlugin = require('html-webpack-plugin')
var path = require('path')

module.exports = {
    entry: './src/app.js',
    output:{
        path: __dirname + '/output',
        filename:'js/[name].bundle.js',
    },
    plugins:[
        new htmlWebpackPlugin({
            template:'index.html',
            filename:'mine.html',
            inject:'body',
        })
    ],
    module:{
       loaders:[
        {
            test:/\.js$/,
            loader:'babel-loader',
            include:path.resolve(__dirname,'src'),
            exclude:path.resolve(__dirname,'node_module'),
            query:{
                presets:['latest']
            }
        }
       ],
        rules: [
            {test: /\.css$/,use: 
            [ 
            {loader:'style-loader'}, 
            {loader:'css-loader' }, 
            {loader:'postcss-loader', options:{ plugins:[ require('postcss-import')(),require('autoprefixer')()  ] } }
            ] 
            },
            {
                test: /\.less$/,
                use: [
                  'style-loader',
                  { loader: 'css-loader'},
                    {loader:'postcss-loader', options:{ plugins:[ require('postcss-import')(),require('autoprefixer')()  ] } },
                  'less-loader',

                ]
              },
            {

            test: /\.html$/,

            use: [ {

              loader: 'html-loader'

            }],

            },
            {

            test: /\.(png|jpg|gif|svg|jpeg)$/i,
            loader:'url-loader',
            query:{
                limit:20000,
                name:'assets/[name]-[hash:5].[ext]'
            }
            }
            
            ],
    },
}

